﻿using Microsoft.AspNetCore.DataProtection;

namespace GameView.Comment
{
    public static class SimpleDataProtector
    {
        private static readonly IDataProtector _protector;

        static SimpleDataProtector()
        {
            // 创建一个临时的 DataProtectionProvider
            // 实际项目中应该从DI容器获取并配置
            var provider = DataProtectionProvider.Create("GameView");
            _protector = provider.CreateProtector("1243edasfq23453r@#3QWTQ2");
        }

        public static string Encrypt(this string plainText)
        {
            return _protector.Protect(plainText);
        }

        public static string Decrypt(this string encryptedText)
        {
            return _protector.Unprotect(encryptedText);
        }
    }
}